//Demo
layui.use(['form', 'jquery', 'layer'], function () {
    var form = layui.form;
    var $ = layui.jquery;
    var layer = layui.layer;

    //监听提交
    form.on('submit(formDemo)', function (data) {
        var currentpriceProduct = $('input[name=currentpriceProduct]').val();
        var bPrice = isNaN(currentpriceProduct);
        //校验价格
        if (currentpriceProduct==''&&bPrice==true){
            return;
        }
        $.ajax({
            url: '/goodsTable/getSearchProduct?result=1',
            type: 'post',
            dataType: 'json',
            data: data.field,
            success: function (data) {
                parent.tablereload(data.data);//访问父页面方法
                var layer = parent.layer;
                layer.close(layer.index);
            }
        });
        return false;
    });
    //下拉框
    getChanName();
    function getChanName() {
        $.ajax({
            url: "/goodsTree/getTree",
            type: 'post',
            dataType: 'json',
            success: function (data) {
                var d = eval(data.data);
                $("#categroyId").append("<option value=''></option>");
                for(var i = 0; i < d.length-1; i++) {
                    var id = d[i].categroyId;
                    var name = d[i].title;
                    $("#categroyId").append("<option value='" + id + "'>" + name + "</option>");
                }
                //刷新下拉框
                form.render('select');
            }
        })
    }
});